package cn.jiyun.controller;

import cn.jiyun.entity.ResultClass;
import cn.jiyun.entity.day10.TopicVO;
import cn.jiyun.entity.day11.TestPaper;
import cn.jiyun.entity.day11.TestPaperDTO;
import cn.jiyun.entity.day11.TestPaperVO;
import cn.jiyun.entity.day11.UserTestPaperOver;
import cn.jiyun.entity.day12.*;
import cn.jiyun.entity.day13.User;
import cn.jiyun.entity.day15.TrainDTO;
import cn.jiyun.entity.day9.*;
import cn.jiyun.service.DayEightService;
import cn.jiyun.service.DayNineService;
import cn.jiyun.service.DayTenService;
import cn.jiyun.service.fegin.*;
import com.alibaba.cloud.commons.lang.StringUtils;
import com.alibaba.fastjson.JSON;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.*;
import java.util.stream.Collectors;

/**
 * @Author sjt
 * @Date 2023/8/23 17:03
 * @PackageName: cn.jiyun.controller.IndexController
 */
@RestController
@RequestMapping("/index")
public class IndexController {
    @Autowired
    ContestFeginService contestFeginService;
    @Autowired
    TrainFeginService trainFeginService;
    @Autowired
    CourseFeginService courseFeginService;
    @Autowired
    TestPaperFeginService testPaperFeginService;
    @Autowired
    TabsFeginService tabsFeginService;
    @Autowired
    DirectoryFeginService directoryFeginService;
    @Autowired
    TopicFeginService topicFeginService;
    @Autowired
    UserFeginService userFeginService;

    @Autowired
    RedisTemplate redisTemplate;
    //代码写在controller不标准
    //day08后改用每天的代码对应每一天的一个service内写业务



    //day11
    @Autowired
    DayTenService dayTenService;
    //查询用户历史测验的个数
    @GetMapping("/findUserHistoryDetectionCount")
    private ResultClass findUserHistoryDetectionCount(Integer uid){
        return dayTenService.findUserHistoryDetectionCount(uid);
    }
    //完善测试功能(存储答案,因为后面有可以查询每次测试记录的功能)
    @PostMapping("/addTestPaperOverAnswers")
    private ResultClass addTestPaperOverAnswers(Integer oid,@RequestBody String[] arr){
//        System.out.println(arr);
//        System.out.println(requestMap);
//        System.out.println(map);
        return dayTenService.addTestPaperOverAnswers(oid,arr);
    }
    //查询当前登录人的课程列表
    @PostMapping("/selectLoginUserCourseList")
    private ResultClass selectLoginUserCourseList(@RequestBody ContestDTO dto,Integer uid){
        return dayTenService.selectLoginUserCourseList(dto,uid);
    }
    //查询当前登录人的所有历史测验记录
    @PostMapping("/selectLoginUserTestPaperOverList")
    private ResultClass selectLoginUserTestPaperOverList(@RequestBody TestPaperDTO dto,Integer uid){
        return dayTenService.selectLoginUserTestPaperOverList(dto,uid);
    }
    //查询历史测验的答案
    @GetMapping("/findhistoryTestPaperAnswer")
    private ResultClass findhistoryTestPaperAnswer(Integer id){
        return dayTenService.findhistoryTestPaperAnswer(id);
    }
    //查询测验的试卷
    @GetMapping("/selecttestpaper")
    private ResultClass selecttestpaper(Integer pid){
        return dayTenService.selecttestpaper(pid);
    }
    //查询当前登录人的竞赛列表
    @PostMapping("/selectLoginUserContestList")
    private ResultClass selectLoginUserContestList(Integer uid,@RequestBody ContestDTO contestDTO){
        return dayTenService.selectLoginUserContestList(uid,contestDTO);
    }
    //查询登录人培训列表
    @PostMapping("/selectLoginUserTrainList")
    private ResultClass selectLoginUserTrainList(Integer uid,@RequestBody TrainDTO trainDTO){
        return dayTenService.selectLoginUserTrainList(uid,trainDTO);
    }
//修改用户头像
    @GetMapping("/changeLoginUserPictrue")
    private ResultClass changeLoginUserPictrue(Integer uid,String pictrue){
        return dayTenService.changeLoginUserPictrue(uid,pictrue);
    }
    //修改密码
    @GetMapping("/changeLoginUserPassword")
    private ResultClass changeLoginUserPassword(Integer uid,String password){
        return dayTenService.changeLoginUserPassword(uid,password);
    }
    //重置密码
    @GetMapping("/resettingLoginUserPassword")
    private ResultClass resettingLoginUserPassword(Integer uid){
        return dayTenService.resettingLoginUserPassword(uid);
    }
    //删除一个战队
    @DeleteMapping("/deleteTeam")
    private ResultClass deleteTeam(Integer tid){
        return dayTenService.deleteTeam(tid);
    }






    //day09-10
    @Autowired
    DayNineService dayNineService;
    //分页查询试卷
    @PostMapping("/findTestPaperList")
    private ResultClass findTestPaperList(@RequestBody TestPaperDTO dto){
        return dayNineService.findTestPaperList(dto);
    }
    //提交模拟考试结果
    @PostMapping("/setUserTestPaperOver")
    private ResultClass setUserTestPaperOver(@RequestBody UserTestPaperOver over){
        return dayNineService.setUserTestPaperOver(over);
    }






    //day08
    @Autowired
    DayEightService dayEightService;
    //查询培训集合
    @PostMapping("/findTrainList")
    private ResultClass findTrainList(@RequestBody TrainDTO dto){
        return dayEightService.findTrainList(dto);
    }
    //查询是否参加了培训
    @GetMapping("findUserIfParticipate")
    private ResultClass findUserIfParticipate(Integer uid,Integer tid){
        return dayEightService.findUserIfParticipate(uid,tid);
    }
    //参加培训
    @GetMapping("participateTrain")
    private ResultClass participateTrain(Integer uid,Integer tid){
        return dayEightService.participateTrain(uid,tid);
    }
    //查询课程集合
    @GetMapping("/findTrainCourseList")
    private ResultClass findTrainCourseList(Integer tid,Integer uid){
        return dayEightService.findTrainCourseList(tid,uid);
    }
    //查询测试集合
    @GetMapping("/findTrainTestPaperList")
    private ResultClass findTrainTestPaperList(Integer tid){
        return dayEightService.findTrainTestPaperList(tid);
    }







// --------------------------------------------------------------------------------------------------------------day07
    @PostMapping("/setUserContestOver")
    /*
     * @description:
     * @author: sjt
     * @date: 2023/8/31 11:28
     * @param: [contestOver]
     * @return: cn.jiyun.entity.ResultClass
     * @annotate:用户完成竞赛/存入竞赛完成信息
    **/
    private ResultClass setUserContestOver(@RequestBody UserContestOver contestOver){
        contestFeginService.setUserContestOver(contestOver);
        return ResultClass.ok(0);
    }
    //查询用户是否参加过竞赛
    @GetMapping("/returnUserIsOverContest")
    private ResultClass returnUserIsOverContest(Integer uid,Integer cid){
        return ResultClass.ok(contestFeginService.returnUserIsOverContest(uid,cid));
    }
    @GetMapping("/findContestResultList")
    /*
     * @description:
     * @author: sjt
     * @date: 2023/8/31 11:29
     * @param: [cid]
     * @return: cn.jiyun.entity.ResultClass
     * @annotate:根据竞赛的id,查询所有参加竞赛用户的完成信息
    **/
    private ResultClass findContestResultList(Integer cid){
        List<UserContestOver> resultList = contestFeginService.findContestResultList(cid);
        List<UserContestOverVO> list=new ArrayList<>();
        for (UserContestOver contestOver : resultList) {
            UserContestOverVO vo = new UserContestOverVO();
            BeanUtils.copyProperties(contestOver,vo);
            vo.setUname(userFeginService.findUserName(contestOver.getUid()));
            list.add(vo);
        }
        Collections.sort(resultList, Comparator.comparingInt(UserContestOver::getSumFen));
        return ResultClass.ok(list);
    }
//    @GetMapping("/findLoginUserContestInfo")
//    private ResultClass findLoginUserContestInfo(Integer cid,Integer uid){
//        return ResultClass.ok(contestFeginService.findLoginUserContestInfo(cid,uid));
//    }
    /*
     * @description:
     * @author: sjt
     * @date: 2023/8/31 11:30
     * @param: [cid, pid, uid]
     * @return: cn.jiyun.entity.ResultClass
     * @annotate:竞赛id,试卷id,用户id/查询用户答题记录
    **/
    @GetMapping("/findTopicAnswerList")
    private ResultClass findTopicAnswerList(Integer cid,Integer pid,Integer uid){
        return ResultClass.ok(contestFeginService.findTopicAnswerList(cid,pid,uid));
    }
// --------------------------------------------------------------------------------------------------------------day07






// --------------------------------------------------------------------------------------------------------------day06
    //清空上一次参赛的答题记录(没用/因为改成相同的竞赛用户只能参加一次答题)
    @GetMapping("/removerUserTestPaperAnser")
    private void removerUserTestPaperAnser(Integer cid,Integer pid,Integer uid){
        contestFeginService.removerUserTestPaperAnser(cid,pid,uid);
    }
    /*
     * @description:
     * @author: sjt
     * @date: 2023/8/31 11:32
     * @param: [cid, pid, uid, tid, answer]
     * @return: cn.jiyun.entity.ResultClass
     * @annotate:存入用户选择的选项信息
    **/
    @GetMapping("/setUserTestPaperAnswer")
    private ResultClass setUserTestPaperAnswer(Integer cid,Integer pid,Integer uid,Integer tid,String answer){
        UserContestAnswer contestAnswer = new UserContestAnswer();
        contestAnswer.setAnswer(answer);
        contestAnswer.setCid(cid);
        contestAnswer.setPid(pid);
        contestAnswer.setUid(uid);
        contestAnswer.setTid(tid);
        contestFeginService.savaUserAnswer(contestAnswer);
        return ResultClass.ok(0);
    }
    /*
     * @description:
     * @author: sjt
     * @date: 2023/8/31 11:32
     * @param: [tid]
     * @return: cn.jiyun.entity.ResultClass
     * @annotate:根据当前试题id/查询当前试题的选项
    **/
    @GetMapping("/findNewOption")
    private ResultClass findNewOption(Integer tid){
        return ResultClass.ok(topicFeginService.findNewOption(tid));
    }
    //查询竞赛的所有试卷
    @GetMapping("/findContestTestPaperList")
    private ResultClass findContestTestPaperList(Integer cid){
        List<Integer> arr=contestFeginService.findContestTestPaperIds(cid);
        List<TestPaper> paperList = testPaperFeginService.findContestTestPaperList(arr);
        return ResultClass.ok(paperList);
    }
    //返回试卷的所有试题
    @GetMapping("/findTestPaperTopicList")
    private ResultClass findTestPaperTopicList(Integer pid){
        List<Integer> arr=testPaperFeginService.findTestPaperTopicIds(pid);
        List<TopicVO> topicList=topicFeginService.findTestPaperTopicList(arr);
        return ResultClass.ok(topicList);
    }
// --------------------------------------------------------------------------------------------------------------day06








// --------------------------------------------------------------------------------------------------------------day05
    //返回所有竞赛的集合
    @PostMapping("/findContestList")
    private ResultClass findContestList(@RequestBody ContestDTO dto){
        PageInfo<Contest> contestList = contestFeginService.findContestList(dto);
        return ResultClass.ok(contestList);
    }
    //查询是否参加过此竞赛
    @GetMapping("/findIsStartOrApplicationFlag")
    private ResultClass findIsStartOrApplicationFlag(Integer uid,Integer cid){
        return ResultClass.ok(contestFeginService.findIsStartOrApplicationFlag(uid,cid));
    }
    //查询用户是否报名过此竞赛
    @GetMapping("/UserApplicationContest")
    private ResultClass UserApplicationContest(Integer uid,Integer cid){
        boolean b=contestFeginService.UserApplicationContest(uid,cid);
        if(b){
            return ResultClass.ok(1).Message("报名成功");
        }else{
            return ResultClass.error().Message("报名失败");
        }
    }
// --------------------------------------------------------------------------------------------------------------day05













// --------------------------------------------------------------------------------------------------------------day04
    //学习一个目录
    @GetMapping("/xueDirectory")
    private ResultClass xueDirectory(Integer cid,Integer uid,Integer did){
        return directoryFeginService.xueDirectory(cid,uid,did);
    }

    //返回二级目录个数
    @GetMapping("/findTowDitectoryNum")
    private ResultClass findTowDitectoryNum(Integer cid){
        Integer num=directoryFeginService.findTowDitectoryNum(cid);
        return ResultClass.ok(num);
    }
    //返回用户已经完成的目录
    @GetMapping("/findUserOverDirectory")
    private ResultClass findUserOverDirectory(Integer cid,Integer uid){
        List<UCDMiddle> list=directoryFeginService.findUserOverDirectory(cid,uid);
        return ResultClass.ok(list);
    }
    //返回目录集合
    @GetMapping("/findDitectoryList")
    private ResultClass findDitectoryList(Integer cid){
        List<DirectoryResult> ditectoryList = directoryFeginService.findDitectoryList(cid);
        return ResultClass.ok(ditectoryList);
    }


//分页 方法
    private List<CourseVO> pageHaper(List<CourseVO> list, Integer pageNum, Integer pageSize){
        List<CourseVO> page = list.stream()
                .skip((pageNum-1) * pageSize)     // 跳过前面的元素
                .limit(pageSize)                  // 限制元素数量
                .collect(Collectors.toList());
        return page;
    }
//查询标签集合
    @GetMapping("/findTbasList")
    private ResultClass findTbasList(){
        return ResultClass.ok(tabsFeginService.findTbasList());
    }
    //查询课程集合
    @PostMapping("/findCoursList")
    private ResultClass findCoursList(@RequestBody CourseDTO dto){
        //太特么多了不加注解了,想死
        //太特么多了不加注解了,想死
        //太特么多了不加注解了,想死
        //太特么多了不加注解了,想死
        //太特么多了不加注解了,想死
        //太特么多了不加注解了,想死
        if (dto.getModel().equals("2")){
            List<CourseVO> courseList = findZanSortCourseList(dto);

            List<CourseVO> list = pageHaper(courseList, dto.getPageNum(), dto.getPageSize());

            PageInfo<CourseVO> info = new PageInfo<>();
            info.setTotal(courseList.size());
            info.setPageSize(dto.getPageSize());
            info.setPageNum(dto.getPageNum());
            info.setList(list);

            return ResultClass.ok(info);
        }
        List<CourseVO> courseList=courseFeginService.findCourseList(dto);
        List<CourseVO> list=findCourseXueNumAndZanNum(courseList);

        list=pageHaper(list, dto.getPageNum(), dto.getPageSize());

        PageInfo<CourseVO> info = new PageInfo<>();
        info.setTotal(courseList.size());
        info.setPageSize(dto.getPageSize());
        info.setPageNum(dto.getPageNum());
        info.setList(list);

        return ResultClass.ok(info);
    }
// --------------------------------------------------------------------------------------------------------------day04





// --------------------------------------------------------------------------------------------------------------day03
    private List<CourseVO> findCourseXueNumAndZanNum(List<CourseVO> list) {
        Map<String,String> zanMap = redisTemplate.opsForHash().entries("课程点赞");
        for (CourseVO vo : list) {
//            赋zan
            String str = zanMap.get(String.valueOf(vo.getCid()));
            if(StringUtils.isBlank(str))str="";
            vo.setZan(str);
            int num=0;
            if(StringUtils.isNotBlank(str)){
                String[] split = str.split("uid:");
                num=split.length-1;
            }
//            赋赞的个数
            vo.setZanNum(num);
//            赋值学习人数
            Integer courseXueCount = trainFeginService.findCourseXueCount(vo.getCid());
//            Integer xueNum=courseFeginService.findCourseXueNum(vo.getCid());
            vo.setXueNum(courseXueCount);
        }
        return list;
    }

    private List<CourseVO> findZanSortCourseList(CourseDTO dto) {
//        取出所有课程的点赞
        Map<String,String> zanMap = redisTemplate.opsForHash().entries("课程点赞");
//        计算点赞数量
        Map<String,Integer> map=new HashMap<>();
        for (Map.Entry<String, String> entry : zanMap.entrySet()) {
            int num=0;
            if(StringUtils.isNotBlank(entry.getValue())){
                String[] split = entry.getValue().split("uid:");
                num=split.length-1;
            }
            map.put(entry.getKey(),num);
        }
//        用于返回的结果集实体类
        List<CourseVO> resultList=new ArrayList<>();
        // 将map集合中的entry按照value值进行排序
        List<Map.Entry<String, Integer>> entryList = new ArrayList<>(map.entrySet());
        Collections.sort(entryList, (a, b) -> b.getValue().compareTo(a.getValue()));

        for (int i = 0; i < entryList.size(); i++) {
            String key = entryList.get(i).getKey();
            Course course = courseFeginService.selectOne(key);
//            查询条件
            if(StringUtils.isNotBlank(dto.getTag())){
                if(!course.getTag().contains(dto.getTag()))continue;
            }
            if(StringUtils.isNotBlank(dto.getCname())){
                if(!course.getCname().contains(dto.getCname()))continue;
            }
                CourseVO courseVO = new CourseVO();
                BeanUtils.copyProperties(course,courseVO);

                Integer count=trainFeginService.findCourseXueCount(course.getCid());

                courseVO.setXueNum(count);
                courseVO.setZanNum(entryList.get(i).getValue());

                courseVO.setZan(zanMap.get(String.valueOf(course.getCid()))==null?"":zanMap.get(String.valueOf(course.getCid())));

                resultList.add(courseVO);
        }
        return resultList;
    }
//    查询最新的四个培训
    @GetMapping("/findNewFourTrain")
    public ResultClass findNewFourTrain(){
        return trainFeginService.findNewFourTrain();
    }
//    查询最新的四个试卷
    @GetMapping("/findNewFourTestPaper")
    public ResultClass findNewFourTestPaper(){
        List<TestPaperVO> newFourTestPaper = testPaperFeginService.findNewFourTestPaper();
        for (TestPaperVO vo : newFourTestPaper) {
            vo.setOverNum(0);
            Integer overNum = testPaperFeginService.selectTestPaperOverNum(vo.getId());
            vo.setOverNum(overNum);
        }
        return ResultClass.ok(newFourTestPaper);
    }
//查询最新的四个课程
    @GetMapping("/findNewFourCourse")
    public ResultClass findNewFourCourse(){
        List<CourseVO> courseVOList=courseFeginService.findNewFourCourse();
//查询学习人数/计算点赞个数
        for (CourseVO vo : courseVOList) {
            Integer xueCount=trainFeginService.findCourseXueCount(vo.getCid());

            String zan = String.valueOf(redisTemplate.opsForHash().get("课程点赞", String.valueOf(vo.getCid())));
            int num=0;
            if(StringUtils.isNotBlank(zan)){
                String[] split = zan.split("uid:");
                num=split.length-1;
            }
            vo.setZanNum(num);
            vo.setXueNum(xueCount);
            vo.setZan(zan);
        }
        return ResultClass.ok(courseVOList);
    }
// --------------------------------------------------------------------------------------------------------------day03


// --------------------------------------------------------------------------------------------------------------day02

    //     查询课程的数量
    @GetMapping("/findContestCount")
    public ResultClass findCourseCount(Integer uid){
        return ResultClass.ok(contestFeginService.findContestCount(uid));
    }
    //    查询培训和课程的数量
    @GetMapping("/findTrainAndCourseCount")
    public ResultClass findTrainCount(Integer uid){
        return ResultClass.ok(trainFeginService.findTrainCount(uid));
    }
//查询点赞数量最多的四个课程
    @GetMapping("/findFourCountMaxCourse")
    public ResultClass findFourCountMaxCourse(){
//        从redis取出所有课程的点赞
        Map<String,String> zanMap = redisTemplate.opsForHash().entries("课程点赞");
//        计算点赞的数量
        Map<String,Integer> map=new HashMap<>();
        for (Map.Entry<String, String> entry : zanMap.entrySet()) {
            int num=0;
            if(StringUtils.isNotBlank(entry.getValue())){
                String[] split = entry.getValue().split("uid:");
                num=split.length-1;
            }
            map.put(entry.getKey(),num);
        }
//        用于返回的结果集实体类
        List<CourseVO> resultList=new ArrayList<>();

//        List<String> keyList = new ArrayList<>();

        // 将map集合中的entry按照value值进行排序
        List<Map.Entry<String, Integer>> entryList = new ArrayList<>(map.entrySet());
        Collections.sort(entryList, (a, b) -> b.getValue().compareTo(a.getValue()));
// 将排序后的课程信息存入返回的结果集的集合中
        for (int i = 0; i < 4; i++) {
            String key = entryList.get(i).getKey();
            Course course = courseFeginService.selectOne(key);
            CourseVO courseVO = new CourseVO();
            BeanUtils.copyProperties(course,courseVO);

            Integer count=trainFeginService.findCourseXueCount(course.getCid());

            courseVO.setXueNum(count);
            courseVO.setZanNum(entryList.get(i).getValue());
            courseVO.setZan(zanMap.get(String.valueOf(course.getCid())));

            resultList.add(courseVO);
        }

//如果点赞数量重复无法输出最多的四个只能输出三个


//        // 创建排序集合
//        SortedSet<Map.Entry<String, Integer>> sortedSet = new TreeSet<>((e1, e2) -> e2.getValue().compareTo(e1.getValue()));
//
//        // 遍历 Map，将 Entry 添加到排序集合中
//        for (Map.Entry<String, Integer> entry : map.entrySet()) {
//            sortedSet.add(entry);
//        }
//
//
//
//        List<CourseVO> resultList=new ArrayList<>();
//
//        Iterator<Map.Entry<String, Integer>> iterator = sortedSet.iterator();
//        for (int i = 0; i < 4 && iterator.hasNext(); i++) {
//            Map.Entry<String, Integer> entry = iterator.next();
//            Course course = courseFeginService.selectOne(entry.getKey());
//            CourseVO courseVO = new CourseVO();
//            BeanUtils.copyProperties(course,courseVO);
//
//            Integer count=trainFeginService.selectXueCount(course.getCid());
//
//            courseVO.setXueNum(count);
//            courseVO.setZanNum(entry.getValue());
//            resultList.add(courseVO);
//        }






//        System.out.println(map);
        return ResultClass.ok(resultList);


//学习人数最多的前四个


//        List<String> maxCourse = trainFeginService.findFourCountMaxCourse();
//
//        List<CourseVO> list=new ArrayList<>();
//        for (String s : maxCourse) {
//            CourseVO courseVO = new CourseVO();
//
//            String[] split = s.split("#");
//            Course course = courseFeginService.selectOne(split[0]);
//
//            BeanUtils.copyProperties(course,courseVO);
//            courseVO.setXueNum(Integer.valueOf(split[1]));
//            Integer num = (Integer) redisTemplate.opsForHash().get("课程点赞数量", String.valueOf(course.getCid()));
//
//            if(num!=null){
//                courseVO.setZanNum(num);
//            }else{
//                courseVO.setZanNum(0);
//            }
//
//            list.add(courseVO);
//        }
//        return ResultClass.ok(list);

    }
    // 点赞
    @GetMapping("/addZan")
    private ResultClass addZan(Integer cid, HttpServletRequest request){
        //取出当前用户信息
        String token = request.getHeader("token");
        User user = JSON.parseObject(String.valueOf(redisTemplate.opsForHash().get("用户登录信息", token)), User.class);
        //取出当前用户的点赞
        String zan = (String) redisTemplate.opsForHash().get("课程点赞", String.valueOf(cid));
        //修改后的内容重新存入redis
        redisTemplate.opsForHash().put("课程点赞",String.valueOf(cid),zan+"uid:"+user.getUid());
        return ResultClass.ok(1).Message("点赞成功");
    }
    // 取消点赞
    @GetMapping("/noZan")
    private ResultClass noZan(Integer cid, HttpServletRequest request){
        //取出当前用户信息
        String token = request.getHeader("token");
        User user = JSON.parseObject(String.valueOf(redisTemplate.opsForHash().get("用户登录信息", token)), User.class);
        //取出当前用户的点赞
        String zan = (String) redisTemplate.opsForHash().get("课程点赞", String.valueOf(cid));
        //替换为空串(取消点赞)
        String replace = zan.replace("uid:" + user.getUid(), "");
//修改后的内容重新存入redis
        redisTemplate.opsForHash().put("课程点赞",String.valueOf(cid),replace);
        return ResultClass.ok(1).Message("取消成功");
    }
// --------------------------------------------------------------------------------------------------------------day02
}
